package cn.kgc.springcloud.nacos.controller;

import cn.kgc.springcloud.nacos.client.PermissionClient;
import cn.kgc.springcloud.nacos.entity.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: mosin
 * @version: v1.0  2022/8/17
 */
@RequestMapping("role")
@RestController
public class RoleController {

    @Value("${server.port}")
    private Integer port;

    @Autowired
    private PermissionClient permissionClient;

    @RequestMapping("test1")
    public String  test1(){
        return "role controller ok port:"+port ;
    }


    @RequestMapping("test2")
    public String  test2(){
        //  1. 根据服务名拉取请求地址  2. 发动http请求
        String s = permissionClient.test1();
        return "role controller ok info:"+s ;
    }


    @RequestMapping("test3")
    public String  test3(Integer id){
        //根据角色id 查询权限信息
        System.out.println("id = " + id);
        String s = permissionClient.test2(id);
        return "role controller ok info:"+s ;
    }

    @RequestMapping("test4")
    public String  test4(Integer id){
        //根据权限id 查询权限信息
        String s = permissionClient.test3(id);
        return "role controller ok info:"+s ;
    }

    @RequestMapping("test5")
    public String  test5(Role role){

        System.out.println("role = " + role);
        String s = permissionClient.test4(role);
        return "role controller ok info:"+s ;
    }

    @RequestMapping("test6")
    public String  test6(Integer[] ids){
        String s = permissionClient.test5(ids);
        return "role controller ok info:"+s ;
    }

    @RequestMapping("test7")
    public Role  test7(Integer id){
        Role role = permissionClient.test6(id);
        //String  json  {"id":20,"name":"admin"}
        System.out.println("role = " + role);
        return role ;
    }

}
